 
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

#define ll long long
#define MAX 200200  // 需要定义MAX

int read() {
    int x = 0;
    bool t = false;
    char ch = getchar();
    while ((ch < '0' || ch > '9') && ch != '-') {
        ch = getchar();
    }
    if (ch == '-') {
        t = true;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return t ? -x : x;
}

int n, m, a[MAX];
int t[MAX];
vector<int> V[MAX];
ll ans = 0;

int lowbit(int x) {
    return x & (-x);
}

void add(int x, int a) {
    while (x <= m) {
        t[x] += a;
        x += lowbit(x);
    }
}

int getsum(int x) {
    int r = 0;
    while (x) {
        r += t[x];
        x -= lowbit(x);
    }
    return r;
}

int main() {
    n = read();
    m = read();
    for (int i = 1; i <= n; i++) {
        a[i] = read();
        V[m - a[i]].push_back(i);
        ans += getsum(m - a[i] - 1);
        add(m - a[i], 1);
    }
    
    printf("%lld\n", ans);
    for (int k = 1; k < m; k++) {
        for (int j = 0; j < V[k].size(); j++) {  // 修正语法错误
            int p = V[k][j];
            ans -= n - p - (j - 1);
            ans += p - j;
        }
        printf("%lld\n", ans);
    }
    return 0;
}
 